﻿Public Class frmThanhToan

    Private Sub frmThanhToan_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim sql As String = "select * from ThanhToan"
        Dim DATA As New ketnoidulieu()
        dgvthanhtoan.DataSource = DATA.ExcuteDataTable(sql)
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim sql As String = String.Format("Insert into ThanhToan(MaHoaDon, MaHopDong, NgayThanhToan,SoTienThanhToan,SoTienNo) values ('" & txtmahoadon.Text & "','" & txtmahopdong.Text & "', '" & txtngaytra.Text & "','" & txtsotien.Text & "','" & txtno.Text & "')")
        Dim INS As New ketnoidulieu()
        INS.SQL_ExecuteNonQuery(sql)
        Dim sl As String = "select * from ThanhToan"
        dgvthanhtoan.DataSource = INS.ExcuteDataTable(sl)
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Dim sql As String = String.Format("select * from ThanhToan where MaHoaDon='{0}' or MaHopDong='{1}'", txthoad.Text, txthd.Text)
        Dim DATA As New ketnoidulieu()
        dgvthanhtoan.DataSource = DATA.ExcuteDataTable(sql)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If txtmahoadon.Text = "" Then
            MsgBox(" Bạn Phải Nhập Giá Trị Cấn Xóa !!! ")
        Else
            Dim sql As String = String.Format("delete * from Nha where MaHoaDon = '" & txtmahoadon.Text & "'")
            Dim KN As New ketnoidulieu()
            KN.SQL_ExecuteNonQuery(sql)
            Dim sl As String = "select * from ThanhToan"
            dgvthanhtoan.DataSource = KN.ExcuteDataTable(sl)
        End If
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Dim sql As String = String.Format("Update ThanhToan Set MaHopDong ='{0}',NgayThanhToan='{1}',SoTienThanhToan='{2}',SoTienNo='{3}' where MaHoaDon = '" & txtmahoadon.Text & "'", txtmahopdong.Text, txtngaytra.Text, txtsotien, txtno.Text)
        Dim INS As New ketnoidulieu()
        INS.SQL_ExecuteNonQuery(sql)
        Dim sl As String = "select * from ThanhToan"
        dgvthanhtoan.DataSource = INS.ExcuteDataTable(sl)
    End Sub
End Class